import { RouteNameEnum } from '@/config/router_config/router_components';
import useUserStore from '@/config/pania_store/module/user_store';
import { router } from '@/config/router_config';
import { Loading } from '@/global';
export enum AccountType {
  UserName,
  PhoneNumber,
  Email
}
export interface LoginUser {
  userName: string;
  password: string;
  accountType: AccountType;
}
export async function login (loginUser: LoginUser, loading: Loading): Promise<void> {
  const userStore = useUserStore();
  loading.status = true;
  await userStore.login(loginUser);
  loading.status = false;
}
export async function logout (): Promise<void> {
  const userStore = useUserStore();
  await userStore.logout();
  await router.push({ name: RouteNameEnum.login });
}
